<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
</head>
<body>
  <div id="test">
    <!-- 
      使用v-for遍历数组
      用法: v-for="item in 数组"    "(item, index) in 数组"   同时指定key: :key="item.id"
     -->
     <h3>遍历数组</h3>
     <ul>
      <li v-for="(item,index) in persons" :key="item.id">
        {{index + 1}}--{{item.name}}--{{item.age}}
      </li>
     </ul>
     <h3>遍历对象</h3>
     <ul>
      <li v-for="(item, key) in persons[0]">
       {{key}} -- {{item}}
      </li>
     </ul>
     <h3>遍历字符串</h3>
     <ul>
      <li v-for="(item, index) in persons[1].name">
        {{index}}--{{item}}
      </li>
     </ul>
     <h3>遍历数值</h3>
     <li v-for="(item, index) in persons[0].age">
      {{index}}--{{item}}
     </li>
  </div>

  <script src="../js/vue.js"></script>
  <script>
    new Vue({
      el: '#test',
      data: {
        persons: [
          {id: 1, name: 'Tom', age: 12},
          {id: 2, name: 'Jack', age: 11},
          {id: 3, name: 'Bob', age: 13},
          {id: 5, name: 'Jerry', age: 17},
          {id: 9, name: 'Rose', age: 15}
        ]
      }
    })
  </script>
</body>
</html>